From: Florian Müllner Date: Fri, 20 Mar 2020 11:42:04 +0000 (+0100) Subject: main: Do not warn about missing GDM on each login X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~751^2^2~62 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ff844a2a817133ca64efa4f2d3d0e4ce7247662b;p=gnome-shell.git main: Do not warn about missing GDM on each login We now warn on startup if screen locking isn't available, however for users who choose not to use GDM or logind, repeating the warning on each login is more annoying than helpful. Instead, limit the warning to the first login on which the screen lock became unavailable. That way the notification will still serve the intended purpose of informing the user, but without being perceived as nagging. https://gitlab.gnome.org/GNOME/gnome-shell/issues/2432 --- diff --git a/js/ui/main.js b/js/ui/main.js index b29360423..ebf9b333a 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -93,6 +93,9 @@ let _a11ySettings = null; let _themeResource = null; let _oskResource = null; +Gio._promisify(Gio._LocalFilePrototype, 'delete_async', 'delete_finish'); +Gio._promisify(Gio._LocalFilePrototype, 'touch_async', 'touch_finish'); + function _sessionUpdated() { if (sessionMode.isPrimary) _loadDefaultStylesheet(); @@ -276,11 +279,8 @@ function _initializeUI() { } if (sessionMode.currentMode !== 'gdm' && - sessionMode.currentMode !== 'initial-setup' && - screenShield === null) { - notify(_('Screen Lock disabled'), - _('Screen Locking requires the GNOME display manager.')); - } + sessionMode.currentMode !== 'initial-setup') + _handleLockScreenWarning(); LoginManager.registerSessionWithGDM(); @@ -293,6 +293,32 @@ function _initializeUI() { }); } +async function _handleLockScreenWarning() { + const path = '%s/lock-warning-shown'.format(global.userdatadir); + const file = Gio.File.new_for_path(path); + + const hasLockScreen = screenShield !== null; + if (hasLockScreen) { + try { + await file.delete_async(0, null); + } catch (e) { + if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND)) + logError(e); + } + } else { + try { + if (!await file.touch_async()) + return; + } catch (e) { + logError(e); + } + + notify( + _('Screen Lock disabled'), + _('Screen Locking requires the GNOME display manager.')); + } +} + function _getStylesheet(name) { let stylesheet;